<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>文件上传控件（FLASH）</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="../js/boot.js" type="text/javascript"></script>
    <script src="../js/swfupload/swfupload.js" type="text/javascript"></script>
    <link href="../js/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<input id="fileupload1" class="mini-fileupload" style="width:300px;"  name="file_upload" limitType="*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.bmp;*.BMP" 
    flashUrl="../js/swfupload/swfupload.swf"
    onuploadsuccess="onUploadSuccess" 
    onuploaderror="onUploadError" onfileselect="onFileSelect"/>
    
     <br />
     <input type="button" value="上传" onclick="startUpload()"/>
    <div class="description">
        <h3>Description</h3>
        <p>FileUpload文件上传控件，基于FLASH的swfupload实现，能实现无刷新上传文件功能。</p>
    </div>
    <div style="width:300px;height:300px;border:1px; border-style:solid;border-color:red">
    	<img style="width:100%;height:100%" src="" id="img"></img>
    </div>
</body>
</html>
<script type="text/javascript">
    mini.parse();

    //动态设置url
    var fileupload = mini.get("fileupload1");
    
    var hostUrl = getRootPath();
    fileupload.setUploadUrl(hostUrl+"/rest/upload/file");

    function onFileSelect(e) {
    	
        //alert("选择文件");
    }
    function onUploadSuccess(e) {

        var data = eval('(' + e.serverData + ')');
		$("#img").attr("src", data.errMsg);
        this.setText("");
    }
    function onUploadError(e) {
        alert("上传出错，请重试。" + e.serverData);
    }

    function startUpload() {
        var fileupload = mini.get("fileupload1");
        fileupload.startUpload();
    }


</script>